import 'package:flutter/material.dart';

class UserCommentModel {
  Game? game;
  List<Comment>? comment;

  UserCommentModel({this.game, this.comment});

  factory UserCommentModel.fromJson(Map<String, dynamic> json) {
    return UserCommentModel(
      game: json['game'] == null
          ? null
          : Game.fromJson(json['game'] as Map<String, dynamic>),
      comment: (json['comment'] as List<dynamic>?)
          ?.map((e) => Comment.fromJson(e as Map<String, dynamic>))
          .toList(),
    );
  }

  Map<String, dynamic> toJson() => {
        'game': game?.toJson(),
        'comment': comment?.map((e) => e.toJson()).toList(),
      };
}

class Game {
  String? cover;

  Game({this.cover});

  factory Game.fromJson(Map<String, dynamic> json) => Game(
        cover: json['cover'] as String?,
      );

  Map<String, dynamic> toJson() => {
        'cover': cover,
      };
}

class Comment {
  String? comment;
  int? createTime;
  String? flag;
  // Color? color;

  Comment({this.comment, this.createTime, this.flag});

  factory Comment.fromJson(Map<String, dynamic> json) => Comment(
        comment: json['comment'] as String?,
        createTime: json['create_time'] as int?,
        flag: json['flag'] as String?,
      );

  Map<String, dynamic> toJson() => {
        'comment': comment,
        'create_time': createTime,
        'flag': flag,
      };
}
